package TestTIjiao;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Arrays;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Arrays;

/**
 * @author 李某
 * * @date 2021/11/22
 * *物有本末，事有终始。知其先后者，则近道矣！
 * *荷花开满池塘的前一天还是半塘荷花半塘云。
 */


    @WebServlet("/PUTMethodText")
    public class DataPut extends HttpServlet {
        @Override
        protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            System.out.println("测试输出DoGet");

            // 1.requese 解析请求参数 name=2332905549&pwd=010321
            // 获取name参数
            String id = request.getParameter("id"); // 获取了name
            System.out.println(id);
            String name = request.getParameter("name"); // 获取了name
            System.out.println(name);
            String pwd = request.getParameter("pwd"); // 获取了name
            System.out.println(pwd);

            response.getWriter().write("<h1>" + id + "</h1>");
            response.getWriter().write("<h2>" + name + "</h2>");
            response.getWriter().write("<h3>" + pwd + "</h3>");


            JDBCConnect.adddata(id,name,pwd);
        }

        @Override
        protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            request.setCharacterEncoding("utf-8");
            System.out.println("测试输出DoPost");
            doGet(request, response);
        }

    }




